﻿using TechMadeira.Core.Command;

namespace TechMadeira.Data.Commands
{
    public class CommandCreateSemantic<T> : ICommand where T : ISemantic
    {
        public CommandCreateSemantic()
        {
            Semantic = Repository.Instance.CreateObject<T>();

            Repository.Instance.Remove( Semantic );
            Semantic.Zombie = true;
        }

        public ISemantic Semantic { get; private set; }

        public void Execute()
        {
            Repository.Instance.Append( Semantic );
            Semantic.Zombie = false;
        }

        public void Undo()
        {
            Semantic.Zombie = true;
            Repository.Instance.Remove( Semantic );
        }

        public void Redo()
        {
            Execute();
        }

        public void Abort()
        {
        }
    }
}
